Imports System.Collections.Generic

Public Class SharePointField

    Enum TypeEnum
        Unknown
        Bool
        BusinessData
        ObsoleteChoice
        Computed
        Currency
        DateTime
        File
        Lookup
        Other
        Note
        Number
        Text
        Url
        User
        SingleChoice
        MultiChoice
        LookupMulti
        Counter
    End Enum

    Private _id As String = ""
    Private _displayName As String = ""
    Private _name As String = ""
    Private _isHidden As Boolean = False
    Private _isReadOnly As Boolean = False
    Private _isRequired As Boolean = False
    Private _valueString As String
    Private _maxLength As Integer
    Private _defaultValue As String
    Private _type As SharePointField.TypeEnum
    Private _relatedFields As New List(Of SharePointField)
    Public Property ValidationData As String


    Sub New(ByVal name As String, _
            ByVal id As String, _
            ByVal type As SharePointField.TypeEnum, _
            ByVal displayName As String)

        _name = name
        _id = id
        _displayName = displayName
        _type = type
    End Sub

    Sub New()
    End Sub

    Public Property Id() As String
        Get
            Return _id
        End Get
        Friend Set(ByVal value As String)
            _id = value
        End Set
    End Property

    Public Property DisplayName() As String
        Get
            Return _displayName
        End Get
        Friend Set(ByVal value As String)
            _displayName = value
        End Set
    End Property

    Public Property Name() As String
        Get
            Return _name
        End Get
        Friend Set(ByVal value As String)
            _name = value
        End Set
    End Property

    Public Property IsHidden() As Boolean
        Get
            Return _isHidden
        End Get
        Friend Set(ByVal value As Boolean)
            _isHidden = value
        End Set
    End Property

    Public Property IsReadOnly() As Boolean
        Get
            Return _isReadOnly
        End Get
        Friend Set(ByVal value As Boolean)
            _isReadOnly = value
        End Set
    End Property

    Public Property IsRequired() As Boolean
        Get
            Return _isRequired
        End Get
        Friend Set(ByVal value As Boolean)
            _isRequired = value
        End Set
    End Property


    Public Property Type() As SharePointField.TypeEnum
        Get
            Return _type
        End Get
        Friend Set(ByVal value As SharePointField.TypeEnum)
            _type = value
        End Set
    End Property

    Public Property ValueString() As String
        Get
            Return _valueString
        End Get
        Set(ByVal value As String)
            _valueString = value
        End Set
    End Property


    Public Property MaxLength() As Integer
        Get
            Return _maxLength
        End Get
        Set(ByVal value As Integer)
            _maxLength = value
        End Set
    End Property

    Public Property DefaultValue() As String
        Get
            Return _defaultValue
        End Get
        Set(ByVal value As String)
            _defaultValue = value
        End Set
    End Property

    Friend ReadOnly Property RelatedFields As List(Of SharePointField)
        Get
            Return _relatedFields
        End Get
    End Property

    Friend Overridable Sub ProcessValues(ByVal connector As SharePointConnector, ByVal lcid As Integer)
        Try
            ValueString = ValueString.ToSharePointString(Type, False)
        Catch ex As Exception
            Throw
        End Try
    End Sub

End Class
